<?php
function error404() {
	header('HTTP/1.1 404 Not Found');
	echo '404 not found';
}
function makeSign() {
	if ($_SERVER['REQUEST_METHOD'] === 'post') {
		$param = $_POST;
	} else {
		$param = $_GET;
		unset($param['m'], $param['c'], $param['a']);
	}
	ksort($param);
	$param = http_build_query($param) . '|' . XY_KEY;
	return sha1($param);
}
function checkSign() {
	return TRUE;
	//return $_SERVER['HTTP_SIGN'] === makeSign();
}
function makeJson($result) {
	if (isset($result['error'])) {
		$result['success'] = 0;
	} else {
		$result['success'] = 1;
	}
	return json_encode($result);
}
function autoload($name) {
	if (substr($name, -5) === 'Model') {
		$filename = strtolower(substr($name, 0, strlen($name) - 5)) . '.php';
		if (is_file(ROOT . 'models/' . $filename)) {
			require(ROOT . 'models/' . $filename);
		}
	} elseif (substr($name, 0, 14) === 'vierbergenlars') {
		$filename = ROOT . 'library/' . $name . '.php';
		if (is_file($filename)) {
			require($filename);
		}
	}
}